import http from '@/utils/service';

const API = {
  getCompanyList: '/hoops/getCompany',
  getList: '/hoops/queryHoopsPage',
  add: '/hoops/updataoradd',
  delete: '/hoops/deleteById',
  updateStatus: '/hoops/updateStatus',
};

export interface ListItemInter {
  id: number;
  farmName: string;
  hoopsName: string;
  inventory: number;
  status: boolean;
}

export interface HoopsListInter {
  totalCount: number;
  pageSize: number;
  list: Array<ListItemInter>;
}

export interface HoopsListQueryInter {
  pageSize: number;
  currentPage: number;
  farmName: string;
}

export interface AddHoopsInter {
  id?: number;
  farmName: string;
  hoopsName: string;
}

export interface EditHoopsInter extends AddHoopsInter {
  id: number;
}

export interface updateStatusInter {
  id: number;
  status: boolean;
}
export const getCompanyListApi = () => http.get<string>(API.getCompanyList);

export const HoopsListApi = (data: HoopsListQueryInter) =>
  http.post<HoopsListInter>(API.getList, { data });

export const AddHoopsApi = (data: AddHoopsInter) =>
  http.post(API.add, { data });

export const deleteByIdApi = (id: number) =>
  http.delete(API.delete, { params: { id } });

export const upDateStatusApi = (data: updateStatusInter) =>
  http.post(API.updateStatus, { data });
